﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GBHNawaData.Dao
{
    public class CustomerDao
    {
        public IList<vmsa120_customer_general> GetCustomer()
        {
            using (var db = new GBHNawaDbEntities())
            {
                var customer = (from cus in db.vmsa120_customer_general
                               where cus.mcustname1.Contains("สยามโกลบอลเฮ้าส์")
                               select cus).ToList();
                return customer;
            }
        }

        public vmsa120_customer_general GetCustomerByCusNo(string cusno)
        {
            using (var db = new GBHNawaDbEntities())
            {
                var customer = (from cus in db.vmsa120_customer_general
                               where cus.mcustno.Trim() == cusno.Trim()
                               select cus).FirstOrDefault();

                return customer;
            }
        }

        public List<vmsa120_customer_general> GetCustomerByName(string cusname)
        {
            using (var db = new GBHNawaDbEntities())
            {
                var customer = db.vmsa120_customer_general.SqlQuery("select * from  vmsa120_customer_general where mcustname1 like N'%" + cusname+ "%' and mblock != 'x' and mdel != 'x'");
                    
                return customer.ToList();
            }
        }
    }
}
